<template>
  <el-dialog
    :visible.sync="isShow"
    @close="onClose"
    width="800px"
    center
    append-to-body
    title="审核"
  >
    <el-form
      autocomplete="off"
      ref="dataForm"
      label-width="80px"
      label-position="right"
      :model="editForm"
    >
      <el-form-item
        label="审核状态"
        prop="review_status"
        :rules="{
          required: true,
          message: '请选择审核状态',
          trigger: ['blur'],
        }"
      >
        <el-radio-group v-model="editForm.review_status">
          <el-radio :label="1">通过</el-radio>
          <el-radio :label="0">不通过</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        label="审核结果"
        prop="review_option"
        :rules="{
          required: true,
          message: '请输入审核结果',
          trigger: ['blur'],
        }"
      >
        <el-input
          type="textarea"
          size="medium"
          v-model="editForm.review_option"
          auto-complete="off"
          placeholder="请输入审核结果"
          :autosize="{ minRows: 5, maxRows: 8 }"
        ></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button @click="onClose">取 消</el-button>
      <el-button type="primary" @click="submit" :loading="btnLoading"
        >确 定</el-button
      >
    </div>
  </el-dialog>
</template>

<script>
import { ApipostMDTReviewOrder } from "@/api/index";
export default {
  data() {
    return {
      isShow: false,
      btnLoading: false,
      editForm: {
        review_status: 0,
        review_option: "",
      },
    };
  },
  methods: {
    show(row) {
      this.isShow = true;
      this.row = row;
      console.log(row);
    },
    submit() {
      this.$refs.dataForm.validate().then((_) => {
        this.btnLoading = true;
        let status = this.editForm.review_status == 0 ? "不通过" : "通过";
        ApipostMDTReviewOrder({
          ...this.editForm,
          order_id: this.row.id,
          review_status: status,
        })
          .then((res) => {
            this.$message.success("操作成功！");
            this.onClose();
            this.$emit("refresh");
          })
          .finally((_) => {
            this.btnLoading = false;
          });
      });
    },
    onClose() {
      this.editForm = {
        review_status: 0,
        review_option: "",
      };
      this.isShow = false;
      this.$nextTick((_) => {
        this.$refs.dataForm.clearValidate();
      });
    },
  },
};
</script>

<style>
</style>